package com.ghsc.ghxc.jsb.ui.message.adapter

import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cn.appcore.utils.GlideUtil
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.config.CustKey
import com.ghsc.ghxc.jsb.ui.message.bean.GroupDataResultBeans
import com.ghsc.ghxc.jsb.utils.StringUtil

/**
 * 项目：JingShortVideo
 * 包名：com.bbl.jyShortVideo.ui.chat.adapter
 * 类名：HeadListAdapter
 * 创建时间：2022/10/10 19:10
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class HeadListAdapter (width: Float)  : BaseQuickAdapter<GroupDataResultBeans, BaseViewHolder>(
    R.layout.chat_head_item) {
    var width: Float = 0f

    init {
        this.width = width
    }

    override fun convert(helper: BaseViewHolder, item: GroupDataResultBeans) {
        var llItem = helper.getView<LinearLayout>(R.id.llItem)
        val para1 = llItem.layoutParams
        para1.width = StringUtil.dp2px((width / 5)).toInt() - StringUtil.dp2px(12f).toInt()
        llItem.layoutParams = para1

        if (item.uid == CustKey.CHAT_GROUP_LIST_ADD) {
            helper.setText(R.id.tvName, "邀请")
                .setGone(R.id.imgType, false)
                .setImageResource(R.id.imgType, R.mipmap.chat_group_jia)
                .setGone(R.id.userImgUrl, true)
        } else if (item.uid == CustKey.CHAT_GROUP_LIST_DELETE) {
            helper.setText(R.id.tvName, "删除")
                .setGone(R.id.imgType, false)
                .setImageResource(R.id.imgType, R.mipmap.chat_group_jian)
                .setGone(R.id.userImgUrl, true)
        } else {
            helper.setGone(R.id.imgType, true)
                .setGone(R.id.userImgUrl, false)
                .setText(R.id.tvName, item.nickname)
            GlideUtil.ImageHeadLoad(this.context, item.headimg, helper.getView(R.id.userImgUrl))
//            if (item.roles == 9) {
//                //群主
//                helper.setGone(R.id.llAdmin, false)
////                    .setImageResource(R.id.imgLe, R.mipmap.icon_group1)
//            } else if (item.roles == 8) {
//                //管理
//                helper.setGone(R.id.llAdmin, false)
////                    .setImageResource(R.id.imgLe, R.mipmap.icon_group2)
//            } else {
//                helper.setGone(R.id.llAdmin, true)
////                    .setImageResource(R.id.imgLe, R.mipmap.icon_group3)
//            }

        }

    }
}
